package com.hqd.ch03.v49.beans.factory.config;

import com.hqd.ch03.v49.beans.BeansException;
import com.hqd.ch03.v49.beans.TypeConverter;
import com.hqd.ch03.v49.factory.BeanFactory;

import java.util.Set;

public interface AutowireCapableBeanFactory extends BeanFactory {

    /**
     * 自动注入
     */
    int AUTOWIRE_NO = 0;
    /**
     * 根据名称注入
     */
    int AUTOWIRE_BY_NAME = 1;

    /**
     * 根据类型注入
     */
    int AUTOWIRE_BY_TYPE = 2;

    /**
     * 构造器注入
     */
    int AUTOWIRE_CONSTRUCTOR = 3;

    @Deprecated
    int AUTOWIRE_AUTODETECT = 4;

    String ORIGINAL_INSTANCE_SUFFIX = ".ORIGINAL";


    <T> T createBean(Class<T> beanClass) throws BeansException;

    void autowireBean(Object existingBean) throws BeansException;

    Object configureBean(Object existingBean, String beanName) throws BeansException;


    Object createBean(Class<?> beanClass, int autowireMode, boolean dependencyCheck) throws BeansException;

    Object autowire(Class<?> beanClass, int autowireMode, boolean dependencyCheck) throws BeansException;

    void autowireBeanProperties(Object existingBean, int autowireMode, boolean dependencyCheck)
            throws BeansException;

    void applyBeanPropertyValues(Object existingBean, String beanName) throws BeansException;

    Object initializeBean(Object existingBean, String beanName) throws BeansException;

    Object applyBeanPostProcessorsBeforeInitialization(Object existingBean, String beanName)
            throws BeansException;

    Object applyBeanPostProcessorsAfterInitialization(Object existingBean, String beanName)
            throws BeansException;

    void destroyBean(Object existingBean);


    <T> NamedBeanHolder<T> resolveNamedBean(Class<T> requiredType) throws BeansException;

    Object resolveBeanByName(String name, DependencyDescriptor descriptor) throws BeansException;


    Object resolveDependency(DependencyDescriptor descriptor, String requestingBeanName) throws BeansException;


    Object resolveDependency(DependencyDescriptor descriptor, String requestingBeanName,
                             Set<String> autowiredBeanNames, TypeConverter typeConverter) throws BeansException;

}
